package com.ihomey.linkuphome.base

import android.content.Context
import android.os.Bundle
import android.support.v4.app.Fragment
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.ihomey.linkuphome.util.AnnotateUtil

/**
 * Created by Administrator on 2017/6/16.
 */
abstract class BaseFragment: Fragment() {

    protected abstract fun inflaterView(inflater: LayoutInflater?, container: ViewGroup?, bundle: Bundle?): View

    open fun initWidget(parentView: View){}

    open fun initData() {}

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        Log.d("BaseFragment",javaClass.simpleName+"-----onCreate")
    }


    override fun onAttach(context: Context?) {
        super.onAttach(context)
        Log.d("BaseFragment",javaClass.simpleName+"-----onAttach")
    }

    override fun onDetach() {
        super.onDetach()
        Log.d("BaseFragment",javaClass.simpleName+"-----onDetach")
    }

    override fun onPause() {
        super.onPause()
        Log.d("BaseFragment",javaClass.simpleName+"-----onPause")
    }

    override fun onStart() {
        super.onStart()
        Log.d("BaseFragment",javaClass.simpleName+"-----onStart")
    }

    override fun onResume() {
        super.onResume()
        Log.d("BaseFragment",javaClass.simpleName+"-----onResume")
    }


    override fun onDestroyView() {
        super.onDestroyView()
        Log.d("BaseFragment",javaClass.simpleName+"-----onDestroyView")
    }

    override fun onStop() {
        super.onStop()
        Log.d("BaseFragment",javaClass.simpleName+"-----onStop")
    }

    override fun onDestroy() {
        super.onDestroy()
        Log.d("BaseFragment",javaClass.simpleName+"-----onDestroy")
    }


    override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        val view = inflaterView(inflater, container, savedInstanceState)
        AnnotateUtil.initBindView(this, view)
        initData()
        initWidget(view)
        Log.d("BaseFragment",javaClass.simpleName+"-----onCreateView")
        return view
    }
}